export function beforeAvatarUpload (file){
  let fileName = file.name || ''
  let ext = fileName.split('.')[fileName.split('.').length - 1]
  if (ext !== "mp4") {
    this.$notify({
      title: "失败",
      message: "上传资源只能是 mp4 格式!",
      type: "error",
      duration: 3000
    });
    return false
  }
  if (ext == 'mp4') { // 获取视频时长
    let url = URL.createObjectURL(file);
    let audioElement = new Audio(url);
    let duration;
    let ele = this.$refs.dur
    audioElement.addEventListener("loadedmetadata", function (_event) {
      duration = audioElement.duration; //时长为秒，小数，182.36
      ele.name = duration //目前使用这种方式解决js与vue之间的传值问题
      this.$parent.$data.wDuration = parseInt(duration) //注意传递给接口的时长字段类型要与接口接收的字段类型一致，不然无法获取到值
      console.log("打印路径");
      console.log(url);

      console.log("打印视频时长");
      console.log(duration);
    });
  }

  this.$parent.$data.wFileName = file.name
  this.$parent.$data.wSize = parseFloat(file.size / 1024).toFixed(2) //获取文件大小
}